/**
 * Copyright (c) 2010 BullionXpress.com,
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 */

package com.bullionxpress.client.view;

import java.awt.*;
import java.util.*;

public abstract class Indicator implements IndicatorInterface, Comparable {

    public static int UPPER_INDICATOR = 0;
    public static int LOWER_INDICATOR = 1;
    int type = UPPER_INDICATOR;
    String caption = "";
    private Color col = Color.blue;
    String uid = "";

    public Indicator() {
        uid = createUID();
    }

    public String getUID() {
        return uid;
    }

    public int compareTo(Object o) {
        if (o instanceof Indicator) {
            Indicator g = (Indicator) o;
            if (g.getUID().equals(getUID())) {
                return 0;
            }
        }
        return -1;
    }

    public synchronized String createUID() {
        try {
            Thread.sleep(10);
        } catch (Exception ex) {
        }
        return "" + System.currentTimeMillis();
    }

    public void setCaption(String caption) {
        this.caption = caption;
    }

    public String getCaption() {
        return caption;
    }

    public void setType(int type) {
        this.type = type;
    }

    public int getType() {
        return type;
    }

    public Color getColor() {
        return col;
    }

    public void setColor(Color col) {
        this.col = col;
    }

    public abstract void initialize(IndicatorSettings settings);

    public abstract IndicatorSettingEditor getEditor();

    public abstract String getDescription();

    public abstract boolean isImplemented();
}
